﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SchoolManagementSystem.Controls;
using CoreData;
namespace SchoolManagementSystem.Details
{
    public partial class StockUC : DetailUC
    {
        public StockUC()
        {
            InitializeComponent();
            this.Code = "Stock";
            this.ObjectName = "kho";

            this.Type = new Product_Warehouse();

        }





        protected override long DetailDisplay()
        {
            Product_Warehouse data = new Product_Warehouse();
            if (ID > 0)
            {
                data = (Product_Warehouse)RegisterService.RegisterServices.ProductWareHouseService.GetByID(ID);

            }

            txtname.Text = data.Name;
            txtnote.Text = data.Description;
            txtcode.Text = data.Code;
            ckactive.Checked = data.Active;

            return ID;

        }

        protected override long Save()
        {
            Product_Warehouse data = new Product_Warehouse();
            if (ID > 0)
            {
                data = (Product_Warehouse)RegisterService.RegisterServices.ProductWareHouseService.GetByID(ID);

            }
            data.Code = txtcode.Text;
            data.Name = txtname.Text;
            data.Description = txtnote.Text;
            data.Active = ckactive.Checked;

            ID = RegisterService.RegisterServices.ProductWareHouseService.Save(data);

            return ID;
        }


        public override bool Delete(long SelectedID)
        {

            return RegisterService.RegisterServices.ProductWareHouseService.Delete(RegisterService.RegisterServices.ProductWareHouseService.GetByID(SelectedID));

        }




        private void StockUC_Load(object sender, EventArgs e)
        {
            AddTextChanged(groupControl1.Controls);
        }

        
   


    }
}
